package com.peng.design.rule;

import org.junit.jupiter.api.Test;

/**
 * DemoTest
 *
 * @author lupeng
 * Created on 2022-03-22
 */
public class DemoTest {

    @Test
    public void demo1() {
        Person person = Person.builder()
                .name("zhangsan")
                .age(19)
                .address(Address.builder()
                        .num(111)
                        .name("beijing")
                        .build())
                .build();

        RuleChain<Person> ruleChain = new SimpleRuleChain<>();
        ruleChain.and(new NameRule());
        ruleChain.or(new AgeRule());
        ruleChain.or(new AddressRule());

        System.out.println(new SimpleRulesExecutor().execute(person, ruleChain));
    }
}
